<!--
 * @Author: hq
 * @Date: 2022-05-24 11:33:44
 * @LastEditors: hq
 * @LastEditTime: 2022-06-10 15:17:29
 * @Description: your project
 * @version: 1.0
-->
<template>
  <div>
    <el-tree
      @check="clickDeal"
      :data="treeData"
      show-checkbox
      node-key="id"
      :props="defaultProps"
    >
    </el-tree>
  </div>
</template>

<script>
export default {
  data() {
    return {
      treeData: [
        {
          id: 1,
          label: "一级 1",
          children: [
            {
              id: 4,
              label: "二级 1-1",
              children: [
                {
                  id: 9,
                  label: "三级 1-1-1",
                },
                {
                  id: 10,
                  label: "三级 1-1-2",
                },
              ],
            },
          ],
        },
        {
          id: 2,
          label: "一级 2",
          children: [
            {
              id: 5,
              label: "二级 2-1",
            },
            {
              id: 6,
              label: "二级 2-2",
            },
          ],
        },
        {
          id: 3,
          label: "一级 3",
          children: [
            {
              id: 7,
              label: "二级 3-1",
            },
            {
              id: 8,
              label: "二级 3-2",
            },
          ],
        },
        {
          id: 4,
          label: "一级 4",
          children: [
            {
              id: 9,
              label: "二级 4-1",
            },
            {
              id: 10,
              label: "二级 4-2",
            },
          ],
        },
        {
          id: 1,
          label: "一级 1",
          children: [
            {
              id: 4,
              label: "二级 1-1",
              children: [
                {
                  id: 9,
                  label: "三级 1-1-1",
                },
                {
                  id: 10,
                  label: "三级 1-1-2",
                },
              ],
            },
          ],
        },
        {
          id: 2,
          label: "一级 2",
          children: [
            {
              id: 5,
              label: "二级 2-1",
            },
            {
              id: 6,
              label: "二级 2-2",
            },
          ],
        },
        {
          id: 3,
          label: "一级 3",
          children: [
            {
              id: 7,
              label: "二级 3-1",
            },
            {
              id: 8,
              label: "二级 3-2",
            },
          ],
        },
        {
          id: 4,
          label: "一级 4",
          children: [
            {
              id: 9,
              label: "二级 4-1",
            },
            {
              id: 10,
              label: "二级 4-2",
            },
          ],
        },
      ],
      defaultProps: {
        children: "children",
        label: "label",
      },
    };
  },
  methods: {
    clickDeal(currentObj, treeStatus) {
      //   (currentObj);
      //   (treeStatus);
      //   // 用于：父子节点严格互不关联时，父节点勾选变化时通知子节点同步变化，实现单向关联。
      //   let selected = treeStatus.checkedKeys.indexOf(currentObj.id); // -1未选中
      //   // 选中
      //   if (selected !== -1) {
      //     // 子节点只要被选中父节点就被选中
      //     this.selectedParent(currentObj);
      //     // 统一处理子节点为相同的勾选状态
      //     this.uniteChildSame(currentObj, true);
      //   } else {
      //     // 未选中 处理子节点全部未选中
      //     if (currentObj.childs.length !== 0) {
      //       this.uniteChildSame(currentObj, false);
      //     }
      //   }
    },
  },
};
</script>

<style lang="scss" scoped></style>
